package com.tata.util;

import java.io.PrintWriter;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.apache.struts2.util.ServletContextAware;

import com.opensymphony.xwork2.ActionSupport;

public abstract class BaseAction extends ActionSupport implements
		ServletRequestAware, ServletResponseAware, ServletContextAware {

	protected HttpServletRequest request = null;
	protected HttpServletResponse response = null;
	protected HttpSession session = null;
	protected PrintWriter out = null;
	protected ServletContext servletContext = null;

	public void setServletRequest(HttpServletRequest req) {
		this.request = req;
		if (this.request != null) {
			this.session = this.request.getSession();
		}
	}

	public void setServletResponse(HttpServletResponse res) {
		this.response = res;
		try {
			if (this.response != null) {
				this.out = this.response.getWriter();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void setServletContext(ServletContext con) {
		this.servletContext = con;
	}

	public abstract String execute() throws Exception;
}
